import React, { Suspense } from "react";
import { BrowserRouter, Routes, Route, useRoutes } from "react-router-dom";
import { _ROUTES_LIST } from "./routes";
import BeforeEachRoute from "./beforeEachRoute";

const Index: React.FC = () => {
  return (
    <Suspense>
      <BrowserRouter>
        <Routes>
          {_ROUTES_LIST.map((v, i) => {
            return (
              <Route
                key={i}
                path={v.path}
                element={<BeforeEachRoute route={v}></BeforeEachRoute>}
              ></Route>
            );
          })}
        </Routes>
      </BrowserRouter>
    </Suspense>
  );
};

export default Index;
